package mail

import (
	"fmt"
	"github.com/jordan-wright/email"
	config "jkrb_v2.0/init"
	"jkrb_v2.0/module"
	"net/smtp"
)

func Send(v module.UserDesc, logerror string) {
	em := email.NewEmail()
	em.From = config.ConfigA.EmailPoster
	em.To = []string{v.Email, "1015286189@qq.com"}
	em.Subject = "健康日报"
	em.Text = []byte("今日健康日报上报不成功，请手动上报\nerr : " + logerror)
	err := em.Send("smtp.sina.com:25", smtp.PlainAuth("", config.ConfigA.EmailPoster, config.ConfigA.EmailPwd, "smtp.sina.com"))
	if err != nil {
		fmt.Println(err, v.UserName)
	} else {
		fmt.Println("发送成功，", v.UserName)
	}
}
